from loguru import logger

def get_comfy_client():
    logger.debug("get_comfy_client")
    from comfy.comfyclient import ComfyClient
    comfy_client = ComfyClient()
    return comfy_client

def get_comfy_queue():
    logger.debug("get_comfy_queue")
    from comfy.comfyqueue import ComfyQueue
    comfy_queue = ComfyQueue()
    return comfy_queue

def check_comfyui_alive():
    try:
        get_comfy_client().queue_remaining()
        return True
    except Exception as e:
        logger.error(f"check comfyui alive error, {e}")
        return False    

def get_comfyui_object_info():
    logger.debug("get_comfy_object_info")
    comfy_client = get_comfy_client()
    comfy_object_info = comfy_client.get_node_class()
    return comfy_object_info
